package executables;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;

import data_structs.*;
import errors.DuplicateKey;
import errors.IncorrectNucleotide;

public class HashTester {

	public static void main(String[] args) {

		File file = new File(args[0]);
		HashRB<SequenceWrapper> ht = new HashRB<SequenceWrapper>(50);
		
	    try {
			BufferedReader reader = new BufferedReader(new FileReader(file));
			String txt = null;
			
			while( (txt=reader.readLine()) != null ) {
				String id = txt.substring(1);
				String sequence = reader.readLine();
				SequenceWrapper sw = new SequenceWrapper(id,sequence,1, false);
				ht.add(sw);
			}
			
			SequenceWrapper tester = new SequenceWrapper("5263797","TCTTGTGGTGGTCGGTCACCATCACTTCTC" +
					"CACAGGACTCTCTTTCTTCTTCTTCTTCTTCTTCTTCTTCTTCTTCTTCTTCTCCTTCTTTTGATGCTTCAATCTTCC",1, false);
			if( ht.contains(tester) != null )
				System.out.println("YES!");
			else
				System.out.println("NO!");
			
			tester = new SequenceWrapper("ttttttttttttttt",1, false);
			if( ht.contains(tester) != null )
				System.out.println("YES!");
			else
				System.out.println("NO!");
			
			System.out.println(ht.numObjects());
			
//			TreeMap[] tmarr = ht.allElements();
//			for( TreeMap tm : tmarr ) {
//				Set set = tm.entrySet();
//				for( Object sw : set )
//					System.out.println(sw);
//			}
			
			
				
			
			
			
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IncorrectNucleotide e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (DuplicateKey e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
